<template>
  <ea-dialog
    v-bind="$attrs"
    v-on="$listeners"
    width="400px"
    ref="elDialog"
    :title="title"
    :type="type"
    @submit="submit"
    @reset="$refs.form.resetFields()"
    @closed="end"
  >
    <el-form ref="form" :rules="rules" :model="singleData" label-width="100px">
      <el-form-item label="科目名称" prop="subname">
        <el-input
          v-model="singleData.subname"
          placeholder="请输入科目名称"
        ></el-input>
      </el-form-item>
      <el-form-item label="排序号"  prop="sort">
        <el-input
            v-model="singleData.sort"
            placeholder="请输入排序号"
        ></el-input>
      </el-form-item>
      <el-form-item label="是否私有" prop="isprivate">
        <el-radio-group v-model="singleData.isprivate">
          <el-radio :label="false">公开</el-radio>
          <el-radio :label="true">私有</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
  </ea-dialog>
</template>

<script>
import editAndAdd from "@/mixins/business/editAndAdd";

export default {
  name: "EaSubject",
  mixins: [editAndAdd],
  data() {
    return {
      moduleName: "科目",
      singleData: {
        ishidden: false,
        isprivate: false,
        subid: 0,
        subname: ""
      },
      rules: {
        subname: { required: true, message: "请输入科目名称！" }
      }
    };
  },
  methods: {
    handle() {
      if (this.type === "add") this.singleData.subid = null;
      return this.axios.post("/sys/subject/addOrUpdateSub", this.singleData);
    }
  }
};
</script>

<style scoped></style>
